# Run on R 3.3.0 GUI 1.68 Mavericks build (7202)
# June 3, 2016


##################################
# FIGURE 1 
##################################

library(foreign)
library(ggplot2)
library(gridExtra)

### Set Path
# setwd()

fulldata <- read.dta("data_for_scatter_plots.dta")

attach(fulldata)
summary(fulldata)


# Tax Staff vs. Tax Revenue
taxstaff <- fulldata$taxstaff
taxy <- fulldata$taxy
d <-data.frame(x = taxstaff, y = taxy)

#pdf(".../taxstaff.pdf", width = 11, height = 8)
ggplot(d, aes(x=taxstaff, y=taxy)) +
    geom_point(size = 5) +    # Use hollow circles
    geom_smooth(method=lm, se=FALSE, color = "black") + #don't add shaded confidence region
    xlab("Tax Staff per 1,000 residents") + 
	ylab("Tax Revenue as % of GDP") +
	theme_bw() +  
	theme(axis.text=element_text(size=20), axis.title=element_text(size=20,face="bold"))
#dev.off()
	
	

##################################
# FIGURE A.4
##################################

#### 1. Tax Staff vs. Shadow Economy	

shadow <- fulldata$shadow
d <-data.frame(x = taxstaff, y = shadow)

#pdf(".../shadow.pdf", width = 11, height = 8)
ggplot(d, aes(x=taxstaff, y=shadow)) +
    geom_point(size = 5) +    # Use hollow circles
    geom_smooth(method=lm, se=FALSE, color = "black") + #don't add shaded confidence region
    xlab("Tax Staff per 1,000 residents") + 
	ylab("Shadow Economy as % of GDP") +
	theme_bw() +  
	theme(axis.text=element_text(size=20), axis.title=element_text(size=20,face="bold"))
#dev.off()


#### 2. Average Compliance
countryavgcomp <- fulldata$countryavgcomp
d <-data.frame(x = taxstaff, y = countryavgcomp)

#pdf(".../samplecompliance.pdf", width = 11, height = 8)
ggplot(d, aes(x=taxstaff, y=countryavgcomp)) +
    geom_point(size = 5) +    # Use hollow circles
    geom_smooth(method=lm, se=FALSE, color = "black") + #don't add shaded confidence region
    xlab("Tax Staff per 1,000 residents") + 
	ylab("Country-Average Tax Compliance") +
	theme_bw() +  
	theme(axis.text=element_text(size=20), axis.title=element_text(size=20,face="bold"))
#dev.off()


#### 3. WGI
wgi_2006 <- fulldata$wgi_2006
d <-data.frame(x = taxstaff, y = wgi_2006)

#pdf(".../gov_effectiveness.pdf", width = 11, height = 8)
ggplot(d, aes(x=taxstaff, y=wgi_2006)) +
    geom_point(size = 5) +    # Use hollow circles
    geom_smooth(method=lm, se=FALSE, color = "black") + #don't add shaded confidence region
    xlab("Tax Staff per 1,000 residents") + 
	ylab("Government Effectiveness Index") +
	theme_bw() +  
	theme(axis.text=element_text(size=20), axis.title=element_text(size=20,face="bold"))
#dev.off()

#### 4. PITY
pity <- fulldata$pity
d <-data.frame(x = taxstaff, y = pity)

#pdf(".../pity.pdf", width = 11, height = 8)
ggplot(d, aes(x=taxstaff, y=pity)) +
    geom_point(size = 5) +    # Use hollow circles
    geom_smooth(method=lm, se=FALSE, color = "black") + #don't add shaded confidence region
    xlab("Tax Staff per 1,000 residents") + 
	ylab("Personal Income Tax as % of GDP") +
	theme_bw() +  
	theme(axis.text=element_text(size=20), axis.title=element_text(size=20,face="bold"))
#dev.off()



